<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ page language="java" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";

	String testUrl = request.getScheme();
	String testUrl2 = request.getScheme() + "://" + request.getServerName();

	String targetUrl = (String) request.getAttribute("targetUrl");
	String ifRemoteUrl = "false";
	//同域
	if (targetUrl.startsWith(testUrl2))
	{
		ifRemoteUrl = "false";
	}
	else if (targetUrl.startsWith(testUrl))
	{
		ifRemoteUrl = "true";
	}
	else
	{
		ifRemoteUrl = "false";
	}

	String themePath = (String) session.getAttribute("themePath");
	themePath = (themePath == null ? "default" : themePath);
	String urlContent = (String) request.getAttribute("urlContent");
%>
<html>
	<head>
		<script language="JavaScript">   
			 function closeErrors(){   
			  return   true;   
			  }   
			 window.onerror=closeErrors;
		</script>
		<script type="text/javascript"
			src="<%=request.getContextPath()%>/js/common/jquery-1.7.1.min.js"></script>
		<script type="text/javascript"
			src="<%=request.getContextPath()%>/js/portal/portlet/Ensure.js"></script>
		<script data-proxy='<%=request.getAttribute("data_proxy")%>'
			data-timer='<%=request.getAttribute("data_timer")%>'
			data-frameid='<%=request.getAttribute("data_frameid")%>'
			targetUrl='<%=request.getAttribute("targetUrl")%>'>
	</script>
	</head>
	<body>
		<div id="test_div" style="height: auto;"></div>

		<script type="text/javascript">
			window.onload = showContent();
			function showContent(){
				var flag = '<%=ifRemoteUrl%>'; 
				if(flag =="true"){
					showRemote();
				}else{
					showLocal();
				}
			}
			
			//是跨域访问
			function showRemote(){
		        ensure({
		            html:['/Portal/portal_portlet/iframeUrl.action?targetUrl=<%=request.getAttribute("targetUrl")%>'],parent:'test_div'
		            }, 
		            function()
		            {
				var height = document.body.offsetHeight;
				if(height ==0){
					height = 400;
				}else{
					height += 50;
				}
					var el = parent.document.getElementById('<%=request.getAttribute("data_frameid")%>');
					if (!el) return;
					el.style.height = height + 'px';
					el.src ="<%=request.getAttribute("targetUrl")%>";
		       });
	   	 	}
	   	 	//是同域访问
	   	 	function showLocal(){
	   	 		try{
	   	 			$.ajaxSetup({async:false});
		            $("#test_div").load('<%=request.getAttribute("targetUrl")%>');
	   	 			$.ajaxSetup({async:true});
	   	 		}catch(e){
	   	 		}
	   	 			
			        var iframe_height = 0;
			        if($.browser.msie){
			            iframe_height = document.body.scrollHeight;
			        }else{
			            $("body").children(":visible").each(function(){
			                if($(this).css("position")!="absolute"){
			                    iframe_height+=$(this).height();
			                }
			            });
			        }
			        
					var height = iframe_height;
					if(height ==0){
						height = 400;
					}else{
						height += 50;
					}
					
					var el = parent.document.getElementById('<%=request.getAttribute("data_frameid")%>');
					if (!el) return;
					el.style.height = height + 'px';
					el.src ="<%=request.getAttribute("targetUrl")%>";
	   	 	}
	   	 	
	   	 	
	    </script>
	</body>
</html>
